import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/ui/dialog/dailog.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';
import 'package:app/src/ui/route/works/type18_contract_royalty_rate_apply_check/item/ui_contractroyaltyrateapplycheckchange.dart';

import '../../../../../http/bean/works_2023/contractroyaltyrateapplycheck_bean.dart';

///提成比例审核（基本信息）
class UiContractRoyaltyRateApplyCheck {
  ///data 信息
  ///oldData 历史信息
  static Widget build(
      BuildContext context,
      ContractRoyaltyRateApplyCheckBean? data,
      ContractRoyaltyRateApplyCheckBean? oldData,
      {String? title}) {
    List<Widget> children = [];
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).BaseInfo; //基本信息
    }
    children.add(UiBase.title(context, title)); //标题
    children.add(UiBase.item(context, AppStrings.of(context).ContractCode,
        data?.ContractCode, oldData?.ContractCode,
        isBlue: true, onTap: () {
      UiContractRoyaltyRateApplyCheckChange.goContractDetailsRoute(
          context, data);
    })); //合同编号
    children.add(UiBase.item(context, AppStrings.of(context).OutCode,
        data?.OutCode, oldData?.OutCode)); //合同外部编号
    children.add(UiBase.item(context, AppStrings.of(context).ProjectName,
        data?.ProjectName, oldData?.ProjectName)); //项目名称
    children.add(UiBase.item(context, AppStrings.of(context).CustomerName,
        data?.CustomerName, oldData?.CustomerName)); //客户名称
    children.add(UiBase.item(context, AppStrings.of(context).SalesmanName3,
        data?.SalesmanName, oldData?.SalesmanName,
        isAllowEmpty: true)); //业务经理;(就是 销售经理)
    children.add(UiBase.item(
        context,
        AppStrings.of(context).Businesscommission,
        "${data?.SalesmanRoyaltyRate}" + "%",
        "${oldData?.SalesmanRoyaltyRate}%",
        sufix: InkWell(
          child: Text(
            "\t${AppStrings.of(context).Detailedallocation}\t",
            style: TextStyle(color: Colors.blueAccent),
          ),
          onTap: () {
            //fixme 详情分配=====================================================
            String? content = data?.ModifyContractRoyaltyRate
                ?.getMerchandiserRoyaltyContent(context);
            if (!StringUtils.isEmpty(content)) {
              AppDialog.showDialogWithInfo(context, content: content);
            }
          },
        ))); //fixme 业务提成（字段需要对接接口）
    children.add(UiBase.item(context, AppStrings.of(context).MerchandiserName,
        data?.MerchandiserName, oldData?.MerchandiserName)); //客服经理
    children.add(UiBase.item(
        context,
        AppStrings.of(context).Customerservicecommission,
        "${data?.MerchandiserRoyaltyRate}%",
        "${oldData?.MerchandiserRoyaltyRate}%")); //fixme 客服提成(字段需要对接接口)
    children.add(UiBase.item(context, AppStrings.of(context).SignDate,
        data?.getSignDate(), oldData?.getSignDate())); //签订日期
    children.add(UiBase.item(context, AppStrings.of(context).CreditMonth,
        data?.CreditMonth, oldData?.CreditMonth)); //合同金额
    children.add(UiBase.item(context, AppStrings.of(context).CompanyName,
        data?.CompanyName, oldData?.CompanyName)); //销售公司
    children.add(UiBase.item(context, AppStrings.of(context).ContractNote,
        data?.ContractContent, oldData?.ContractContent)); //合同备注
    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
